#ifndef DATAPROVIDER_H
#define DATAPROVIDER_H

#include "Note.h"
#include "DataBaseAgent.h"
#include <QObject>
#include <CryptoAgent.h>
#include <QStatusBar>

struct AppSettings{
	bool expanded;
	bool showDlgAtStartup;
	bool showPass;
	CipherType::Enum userType;
	QString database;
	int dataViewStyle;
	int windowStyle;

	AppSettings(){
		expanded = true;
		showDlgAtStartup = true;
		showPass = false;
		userType = CipherType::AES;
		database = "notes.mdb";
		dataViewStyle = 1;
		windowStyle = 3;
	}
};

class DataProvider : public QObject
{
	Q_OBJECT

	QList<Note*> _notes;
	DataBaseAgent* _database;
	CryptoAgent* _crypt;
	QStatusBar* _statusBar;
	AppSettings _settings;
	bool _databaseLoaded;

public:
	DataProvider(DataBaseAgent* database, QObject* parent = NULL);

	QList<Note*> getNotesList();
	DataBaseAgent* getDatabase();
	CryptoAgent* getCrypt();

	bool addNote(Note* note);
	bool removeNote(Note* note);
	bool updateNote(Note* note);

	AppSettings* settings() { return &_settings;}
	bool isDBLoaded() { return _databaseLoaded;}

	void loadDatabase();

	void setStatusBar(QStatusBar* statusBar);

public slots:
	void showMessage(QString msg, int timeout = 5000);

signals:
	void noteAdded(Note* note);
	void noteUpdated(Note* note);
	void noteRemoved(Note* note);
	void DBStateChanged();
};

#endif // DATAPROVIDER_H
